package com.lyh.utils;

import java.util.Random;

public class SaltUtils {
    static Random random = new Random();
    /**
     * 生成salt的静态方法
     * @param n 生成随机字符的个数
     * @return salt
     */
    public static String getSalt(int n) {
        char[] chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~!@#$%^&*()_+{}<>?:.".toCharArray();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            char aChar = chars[random.nextInt( chars.length )];
            sb.append(aChar);
        }
        return sb.toString();
    }
}
